#! /bin/bash
function markdown2pdf(){
    basename="$(basename -s .md "$1")"
    metadata_file="$(mktemp)"
    cat <<-EOF > "${metadata_file}"
title:  ${basename}
author: "孔俊"
email: "kongjun18@outlook.com"
EOF
    cp "${metadata_file}" /tmp/dd
    pandoc --pdf-engine=xelatex --metadata-file="${metadata_file}" --toc --toc-depth=4 -s -N --listings -V footer_lerft=' ' -V auto_indentifiers=false -V footer-left=" " -V colorlinks=true -V linkcolor=blue -V urlcolor=red -V footnotes-pretty=true -V listings-disable-line-numbers=true -V listings-no-page-break=true -V toc-own-page=true  --template eisvogel -V CJKmainfont="SimSun" "$1" -o "${basename}.pdf"
}
markdown2pdf "$@"
